#include <linux/module.h>
#include <linux/netfilter_ipv4/ip_tables.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <net/sock.h>
#include <net/route.h>
#include <linux/ip.h>
#include <net/ip.h>
#define sbup printk
static unsigned int ipt_route_hook(unsigned int hook,
				   struct sk_buff **pskb,
				   const struct net_device *in,
				   const struct net_device *out,
				   int (*okfn) (struct sk_buff *))
{
	static int i = 0;
	sbup("%s:%d, i = %d\n", __FUNCTION__, __LINE__, i ++);
	return NF_ACCEPT;
}
static struct nf_hook_ops ipt_ops[] = {
	{
	 .hook = ipt_route_hook,
	 .owner = THIS_MODULE,
	 .pf = PF_INET,
	 .hooknum = NF_IP_POST_ROUTING,
	 .priority = NF_IP_PRI_MANGLE,
	 },
};

static int __init iptable_post_init(void)
{
	int ret;

	ret = nf_register_hooks(ipt_ops, ARRAY_SIZE(ipt_ops));
	if (ret < 0)
		goto cleanup_table;
	return ret;
cleanup_table:
	return ret;
}

static void __exit iptable_post_fini(void)
{
	nf_unregister_hooks(ipt_ops, ARRAY_SIZE(ipt_ops));
}

module_init(iptable_post_init);
module_exit(iptable_post_fini);
MODULE_LICENSE("GPL");
